package cate.game.activity.dailygift.msg;

import cate.common.annotation.OperationSetter;
import cate.common.table.d.GDFunc;
import cate.common.table.d.GDOperation;
import cate.common.util.GameResult;
import cate.game.GameBody;
import cate.game.activity.dailygift.DailyGiftActivity;
import cate.game.client.ClientContext;
import cate.game.client.msg.ClientMsg;
import cate.game.client.msg.MsgConfig;
import cate.game.client.msg.MsgInput;
import cate.game.client.msg.id.MsgIdDailyGift;

@ClientMsg(title = "每日特惠领取免费礼包的请求")
@OperationSetter(value = GDOperation.ACT_DAILY_GIFT)
public class DailyGiftFreeReq implements MsgInput {
    @Override
    public MsgConfig conf() {
        return MsgIdDailyGift.FREE_REQ;
    }

    @Override
    public void execute(GameBody game, ClientContext cc) {
        DailyGiftActivity activity = cc.getRole().getActivity().getEnableActivitySingle(GDFunc.ACT_DAILY_GIFT);
        if (activity == null) {
            cc.getRole().getGame().notice.message(cc.getRole(), "活动未开启");
            return;
        }
        GameResult<DailyGiftActivity> result = activity.takeFreeGift();
        if (!result.ok()) {
            cc.getRole().getGame().notice.message(cc.getRole(), result);
        }else {
            result.data.noticeUpdate();
        }
    }
}
